#include "prescriptiondetailwidget.h"
#include "ui_prescriptiondetailwidget.h"

PrescriptionDetailWidget::PrescriptionDetailWidget(const Prescription& prescription, QWidget *parent) :
    QWidget(parent),
    ui(new Ui::PrescriptionDetailWidget),
    m_prescription(prescription) {
    ui->setupUi(this);
    
    // 设置窗口属性
    setWindowTitle("处方详情");
    setWindowFlags(Qt::Window);
    setAttribute(Qt::WA_DeleteOnClose);
    
    // 显示处方信息
    ui->prescriptionIdLabel->setText(QString::number(prescription.id));
    ui->prescriptionTimeLabel->setText(prescription.prescriptionTime.toString("yyyy-MM-dd HH:mm:ss"));
    ui->doctorNameLabel->setText(QString("医生ID: %1").arg(prescription.doctorId)); // 如果有医生姓名字段可以替换
    ui->medicationsText->setPlainText(prescription.medications);
    ui->dosageLabel->setText(prescription.dosage);
    ui->usageLabel->setText(prescription.usage);
    ui->frequencyLabel->setText(prescription.frequency);
    ui->daysLabel->setText(QString::number(prescription.days));
    ui->notesText->setPlainText(prescription.notes);
}

PrescriptionDetailWidget::~PrescriptionDetailWidget() {
    delete ui;
}

